package com.cn.wanxi.service;

import com.cn.wanxi.dao.NewsDao;
import com.cn.wanxi.dao.NewsImpl;
import com.cn.wanxi.model.NewsModel;
import com.cn.wanxi.model.PageModel;
import com.cn.wanxi.util.GetSqlSession;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * Administrator
 */
public class NewsService {
    private NewsDao newsDao = new NewsImpl();

    public Integer add(NewsModel newsModel) {

        return newsDao.add(newsModel);
    }

    /**
     * 修改新闻数据
     *
     * @param newsModel
     * @return
     */
    public Integer update(NewsModel newsModel) {

        return newsDao.update(newsModel);
    }

    public Integer delete(NewsModel newsModel) {

        return newsDao.delete(newsModel);
    }

    /**
     * 根据id查找新闻信息
     *
     * @param id
     * @return
     */
    public NewsModel findById(Integer id) {

        return newsDao.findById(id);
    }

    public List<NewsModel> findAll() {

        return newsDao.findAll();
    }

    /**
     * 分页
     *
     * @param pageModel
     * @return
     */
    public List<NewsModel> findPage(PageModel pageModel) {

        return newsDao.findPage(pageModel);
    }

    /**
     * 返回总条数
     *
     * @param pageModel
     * @return
     */
    public Integer findCount(PageModel pageModel) {

        return newsDao.findCount(pageModel);
    }

    public  List<NewsModel> findNews(NewsModel newsModel){
        return newsDao.findNews(newsModel);
    }
}
